<!DOCTYPE html>
<html lang="en">
<head>
        {include file="common/meta_new" /}
        <script src="/static/js/layer/layer.js"></script>
</head>
<body class="F5">
<div id="app" class="taskaudit2-page">
    <!-- header -->
    <div class="header">
        <div class="header-height"></div>
        <div class="header-wrap">
            <div class="header-content">
                <div class="left">
                    <a href="{:url('index/Team/auditUser');}" ><div class="go-back"><img src="/static/images/go-back.png" alt=""></div></a>
                    <div class="text">任务审核</div>
                </div>
                <div class="title"></div>
            </div>
        </div>
    </div>
    <div class="top-wrap">
        <div class="left">
            <div class="avatar">
                <img src="{$info['avatar']}" alt="">
            </div>
            <div class="user-info">
                <div class="nickname">{$info['nickname']}</div>
                <div class="phone">{$info['mobile']}</div>
            </div>
        </div>
        <div class="right">ID:{$info['unique_id']}</div>
    </div>
    <div class="content-wrap">
        <div class="title-box">
            <div class="sy"></div>
            <div class="title">店铺订单号</div>
        </div>
        {foreach $info.order_sn as $vo } 
                <div class="order-no">订单号: {$vo}</div>
        {/foreach}
        <div class="hr"></div>
        <div class="red-row">
            <div class="left">
                <span class="label">金额：</span>
                <span class="symbol">￥</span>
                <span class="amount">{$info['order_amount']}</span>
            </div>
            <div class="right"><span id="expiretime">{$info['expiretime']}</span></div>
        </div>
        
        {if $info['status'] ==1}
        <div id="subBtn" class="btn-list">
            <div class="btn" onclick="setAudit(2)">审核通过</div>
            <div class="btn blue"  onclick="setAudit(-2)" >驳回</div>
        </div>
        {/if}
        <div class="reject-title">驳回原因</div>
        <textarea id="note" placeholder="">{$info['note']|default=''}</textarea>
    </div>
</div>
<script src="/static/js/common.js"></script>
<script>
    function sendTimeOut(oid){
        $.post("{:url('index/Team/setOrderTime','',false)}",{'id':oid},function(ret){
            console.log(ret);
        });
    }
    
                function startCountdown(element, seconds) {
                if (seconds == 0) {
                    element.text('超时自动确认');
                    sendTimeOut("{$info['id']}");
                    return;
                }
                const interval = setInterval(() => {
                    if (seconds <= 0) {
                        clearInterval(interval); // 停止倒计时
                        element.text('超时自动确认');
                        sendTimeOut("{$info['id']}");
                    } else {
                        // 计算小时、分钟、秒
                        const hours = String(Math.floor(seconds / 3600)).padStart(2, '0');
                        const minutes = String(Math.floor((seconds % 3600) / 60)).padStart(2, '0');
                        const secs = String(seconds % 60).padStart(2, '0');

                        // 更新 DOM 内容
                        element.text(`倒计时：${hours}:${minutes}:${secs}`);
                        seconds--;
                    }
                }, 1000); // 每秒更新一次
            }
            startCountdown($('#expiretime'),{$info['expiretime']});
            
    function setAudit(status){
        var note = $("#note").val();
        
        $.post("{:url('index/Team/setOrderStatus','',false)}",{'id':"{$info['id']}","status":status,'note':note},function(ret){
            console.log(ret);
            if(ret.code==1){
                layer.msg(ret.msg,{icon:1,time:3000,shade:0.4},function() {
                   window.location.href =ret.url;
                });
            }else{
                layer.msg(ret.msg,{icon:2,time:2000,shade:0.4},function() {
//                    location.reload();
                });
            }
            
        });
    }
            
            
</script>
</body>
</html>